<template>
	<div>
		<div v-for="item in data" :key="item[default_.id]">
			<c-tree-item :data="item" :defaults="default_" @click="clicks"></c-tree-item>
		</div>
	</div>
</template>

<script>
import cTreeItem from './tree-item';
export default {
	props: {
		data: {
			type: [Object, Array],
			required: true,
		},
		default: {
			type: Object,
			default: () => {
				return {
					id: 'id',
					name: 'name',
					children: 'children',
				};
			},
		},
	},
	data() {
		return {
			id: 'id',
			default_: {},
		};
	},
	created() {},
	mounted() {
		console.log(this.default);
		this.default_ = this.default;
		this.id = this.default_.id || this.id;
	},
	components: {
		cTreeItem,
	},
	methods: {
		clicks(data) {
			this.$emit('click', data);
		},
	},
};
</script>
